package com.awifi.dbus.service;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import com.awifi.dbus.dao.IMessageDao;
import com.awifi.dbus.dao.IUserDao;
import com.awifi.dbus.model.User;

@Service("userService")
public class UserService implements IUserService {
	private IMessageDao messageDao;
	private IUserDao userDao;
	
	@Override
	public void add(User user) {
		messageDao.add();
		userDao.add(user);
	}

	public IMessageDao getMessageDao() {
		return messageDao;
	}

	@Resource(name="messageDao")
	public void setMessageDao(IMessageDao messageDao) {
		this.messageDao = messageDao;
	}

	@Override
	public void del(int id) {
		messageDao.del();
		userDao.del(id);
	}

	@Override
	public User load(int id) {
		messageDao.load();
		return userDao.load(id);
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	//可以指定要注入的对象名称，默认就是是通过名称来注入
	//也可以 @Resource(name="userDao")  告诉 spring 把创建好的 userDao 对象注入给 setUserDao( IUserDao userDao )
	@Resource(name="userDao")
	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}
}
